<?php

namespace App\Observers;

use App\Models\GoodsCategory;

class GoodsCategoryObserver
{
    /**
     * Handle the goods category "created" event.
     *
     * @param  \App\GoodsCategory  $goodsCategory
     * @return void
     */
    public function created(GoodsCategory $goodsCategory)
    {
        //
    }

    /**
     * Handle the goods category "updated" event.
     *
     * @param  \App\GoodsCategory  $goodsCategory
     * @return void
     */
    public function updated(GoodsCategory $goodsCategory)
    {
        //
    }

    /**
     * Handle the goods category "deleted" event.
     *
     * @param  \App\GoodsCategory  $goodsCategory
     * @return void
     */
    public function deleted(GoodsCategory $goodsCategory)
    {
        //
    }

    /**
     * Handle the goods category "restored" event.
     *
     * @param  \App\GoodsCategory  $goodsCategory
     * @return void
     */
    public function restored(GoodsCategory $goodsCategory)
    {
//        $parent_info = $goodsCategory->where("id",$goodsCategory->parent_id)->first();
//        if ($parent_info){
//            $data['level'] = $parent_info->level+1;
//            $data['path'] = $parent_info->path."-".$goodsCategory->id;
//        }else{
//            $data['level'] = 0;
//            $data['path'] = $goodsCategory->id;
//        }
//        $goodsCategory->save($data);
    }

    /**
     * Handle the goods category "force deleted" event.
     *
     * @param  \App\GoodsCategory  $goodsCategory
     * @return void
     */
    public function forceDeleted(GoodsCategory $goodsCategory)
    {
        //
    }
}
